// useIdentityCheck.ts
import {useEffect} from 'react';
import {useNavigate} from 'react-router-dom';

// 个人身份检查

export function useIdentityCheck(allowedIdentity: string, redirectPath: string) {
    const navigate = useNavigate();

    useEffect(() => {
        const identity = localStorage.getItem('identity');
        if (identity !== allowedIdentity) {
            navigate(redirectPath);
        }
    }, [allowedIdentity, redirectPath, navigate]);
}
